<template>
  <div>
    <!-- string ref -->
    <p ref="p">hello ref</p>
    <!-- function ref -->
    <p :ref="setRef">hello ref</p>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      pRef: null,
    };
  },
  methods: {
    setRef(p) {
      if (p) {
        this.pRef = p;
      }
    },
  },
  mounted() {
    console.log(this.$refs.p);
  },
};
</script>

<style scoped>
</style>
